﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <title><%=ExamSys.ExamSysName%> <%=ExamSys.ExamSysDesc%></title>
    <STYLE type=text/css>
        * { MARGIN: 0 auto; 
            PADDING: 0px;
            BORDER: 0px;
        }
        html, body {MARGIN: 0 auto;height:100%;background-color:#333;font:12px Arial, Helvetica, sans-serif;color:#333333}
        A { COLOR: #000; TEXT-DECORATION: none }
        A:hover { COLOR: #f30; TEXT-DECORATION: underline}
        div{padding-left:0;}
        INPUT { }
        .txtbox{MARGIN:0; PADDING-BOTTOM: 0px; PADDING-LEFT:3px; PADDING-RIGHT: 0px; PADDING-TOP: 0px}
        td{vertical-align:top;}
        .logotitle{color:#FFF;display:block;margin-top:195px;margin-left:27px;font-weight:bold;font-size:40px;font-family: Arial, Helvetica, sans-serif;}
        </STYLE>
        <script type="text/javascript" src="js/jquery/jquery-1.4.4.min.js"></script>
        <script>
            var _url = "student/index.aspx";
            var COOKIE_NAME = "<%=ExamSys.cookies_name.Trim() %>";
            $(function () {
                if (!navigator.cookieEnabled) {
                    alert('<%= Resources.labels.PleaseOpenCookies %>');
                    return false;
                }
                //登录
                $("#btnlogin").click(function () {
                    login();
                });

            })
            function login() {
                var _xuehao = $("#xuehao");
                var _pwd = $("#pwd");
                if (_xuehao.val() == "") {
                    $("#logininfo").html("<img class='erro' src='images/erro.gif' style='vertical-align:middle' width='16' height='16' border=0 /> <%= Resources.labels.PleaseLoginName %>");
                    _xuehao.focus();
                    return false;
                }
                if (_pwd.val() == "") {
                    $("#logininfo").html("<img class='erro' src='images/erro.gif' style='vertical-align:middle' width='16' height='16' border=0 /> <%= Resources.labels.PleaseLoginPwd %>");
                    _pwd.focus();
                    return false;
                }

                $.ajax({
                    type: "POST", cache: false, url: "p/userlogin.aspx?t=" + new Date().getTime(), data: "n=" + _xuehao.val() + "&p=" + _pwd.val() + "&tt=0",
                    beforeSend: function () { },
                    success: function (getdata) {
                        if (getdata == "") {
                            $("#logininfo").html("<img class='erro' src='images/erro.gif' style='vertical-align:middle' width='16' height='16' border=0 /> <%= Resources.labels.LoginErrNoName %>");
                            _xuehao.focus(); return false;
                        }
                        if (getdata == "pwderr") {
                            $("#logininfo").html("<img class='erro' src='images/erro.gif' style='vertical-align:middle' width='16' height='16' border=0 /> <%= Resources.labels.LoginErrPwd %>");
                            _pwd.focus(); return false;
                        }

                        if (getdata == "teacher") {
                            $("#logininfo").html("<img class='ok' src='../images/ok.gif' style='vertical-align:middle' width='16' height='16' border=0 /> <%= Resources.labels.LoginOk %>");
                            window.location.href = "manage/default.aspx";
                        } else if (getdata == "student") {
                            $("#logininfo").html("<img class='ok' src='images/ok.gif' style='vertical-align:middle' width='16' height='16' border=0 /> <%= Resources.labels.LoginOk %>");
                            window.location.href = "student/index.aspx";
                        }
                        else if (getdata == "admin") {
                            $("#logininfo").html("<img class='ok' src='images/ok.gif' style='vertical-align:middle' width='16' height='16' border=0 /> <%= Resources.labels.LoginOk %>");
                            window.location.href = "admin/default.aspx";
                        } else {
                            $("#logininfo").html("<img class='erro' src='images/erro.gif' style='vertical-align:middle' width='16' height='16' border=0 /> <%= Resources.labels.LoginErr %>");
                            _xuehao.focus(); return false;
                        }
                    },
                    complete: function () { },
                    error: function (getdata) {
                        $("#logininfo").html("<img class='erro' src='images/erro.gif' style='vertical-align:middle' width='16' height='16' border=0 /> <%= Resources.labels.LoginErr %>");
                    }
                });
                return false;
            }
            function setCookies(mail, pwd, uid) {
                var options = { path: '/', expires: 10 };
                var json_str = "";
                $.cookie(COOKIE_NAME, json_str, options);
            }
            document.onkeydown = function (e) {
                e = e || event;
                var key = e.keyCode || e.charCode;
                if (key == 13) {
                    login();
                };
            }
        </script>
</head>
<body>
    <form id="form1" runat="server">
        <table cellpadding=0 cellspacing=0 style="width:1003px;height:251px;background:url(images/login_title.jpg) no-repeat;">
        <tr>
        <td><h1 class="logotitle"><%--<%=ExamSys.ExamSysName%>--%></h1></td>
        <td><h4 class="logoright"><%--<%=ExamSys.ExamSysName%>--%></h4></td>
        </tr>
        </table>
        <table cellpadding=0 cellspacing=0 style="width:1003px;height:516px;background:url(images/login_bg.jpg) repeat-x;">
            <tr>
            <td style="background:url(images/login_leftbj.jpg) no-repeat;width:497px;height:516px;"></td>
            <td style="background:url(images/login_bg.jpg) no-repeat;height:516px;">
                <table cellpadding=0 cellspacing=0 style="height:516px;">
                <tr><td style="height:79px;">&nbsp;</td></tr>
                <tr><td style="width:447px;background:url(images/login_center.jpg) no-repeat;vertical-align:top;">
                    <div style="margin-left:163px;text-align:left; margin-top: 61px;">
                        <div style="margin-left:0px; margin-top:10px;"><input style="width:161px;height:24px;line-height:24px;" id="xuehao" class=txtbox type=text maxlength="20" name=username /></div>
                        <div style="margin-left:0px;margin-top:21px;"><input style="width:161px;height:24px;line-height:24px;" id="pwd" class=txtbox value="" maxlength="20" type=password name=password /></div>
                        <DIV id=btnlogin  style="margin-top: 16px; margin-left:0px;height:27px; line-height:27px;"><A href="javascript:void(0)" sytle="display:block;float:left;"><IMG src="images/login_btn.jpg" width=54 height=27></A><span id="logininfo" style="vertical-align:middle;display:block;">
                        <%= Resources.labels.PleaseLogin%>
                        </span></DIV>
                    </div>
                </td></tr>
                </table>
            </td>
            </tr>
        </table>

    </form>
</body>
</html>
